home *** CD-ROM | disk | FTP | other *** search
- ;;; -*- Scheme -*-
-
- #|
- Description:
- This code tests variable arity procedures and the apply code in cmpproc.m4.
-
- Usage:
- (tag 'pepe 1 2 3 4) -> ((pepe . 1) (pepe . 2) (pepe . 3) (pepe . 4))
- (fix 3.4) -> (3 .4)
- (fix 3 2) -> (1 1)
- (hack 1 2) -> (1 2 c d e ())
- (hack 1 2 3) -> (1 2 3 d e ())
- (hack 1 2 3 4) -> (1 2 3 4 e ())
- (hack 1 2 3 4 5) -> (1 2 3 4 5 ())
- (hack 1 2 3 4 5 6) -> (1 2 3 4 5 (6))
- (hack 1 2 3 4 5 6 7) -> (1 2 3 4 5 (6 7))
- and so on
- |#
-
- (declare (usual-integrations))
-
- (define (tag the-tag . elements)
- (define (inner left)
- (if (null? left)
- '()
- (cons (cons the-tag (car left))
- (inner (cdr left)))))
- (inner elements))
-
- (define (fix a #!optional b)
- (define (kernel x receiver)
- (let ((y (floor x)))
- (receiver y (- x y))))
-
- (if (unassigned? b)
- (kernel a list)
- (kernel (/ a b)
- (lambda (int frac)
- (list int (* b frac))))))
-
- (define (hack a b #!optional c d e . f)
- (if (unassigned? c) (set! c 'c))
- (if (unassigned? d) (set! d 'd))
- (if (unassigned? e) (set! e 'e))
- (list a b c d e f))